package com.metadata_system.ai.response;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.metadata_system.common.db.entity.Project;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

@AllArgsConstructor
@NoArgsConstructor
@Builder
@Data
public class ProjectResponse {
    private Integer id;
    private Integer databaseId;
    private String databaseName;

    private Integer metadataId;
    private String metadataName;

    private String name;
    private Integer dataTotal;
    private String description;
    private Integer type;

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createdTime;
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updatedTime;

    public static ProjectResponse fromEntity(Project project) {
        return ProjectResponse.builder()
                .id(project.getId())
                .databaseId(project.getDatabaseId())
                .databaseName(project.getDatabaseName())
                .metadataId(project.getMetadataId())
                .metadataName(project.getMetadataName())
                .name(project.getName())
                .dataTotal(project.getDataTotal())
                .description(project.getDescription())
                .type(project.getType())
                .createdTime(project.getCreatedTime())
                .updatedTime(project.getUpdatedTime())
                .build();
    }

    public static List<ProjectResponse> fromEntity(List<Project> projects) {
        return projects.stream().map(ProjectResponse::fromEntity).collect(Collectors.toList());
    }



}
